#include <iostream>
#include <vector>
#include <unordered_set>
#include <string>
#include <unordered_map>
using namespace std;
class Solution {
public:
    string toLower(const string& str) {
        string res;
        for (const auto& ch : str) {
            res += tolower(ch);
        }

        return res;
    }

    string devowel(const string& str, unordered_set<char>& vowelSet) {
        string res;
        for (const auto& ch : toLower(str)) {
            if (vowelSet.count(ch)) {
                res += '*';
            }
            else {
                res += tolower(ch);
            }
        }

        return res;
    }
    vector<string> spellchecker(vector<string>& wordlist, vector<string>& queries) {
        unordered_set<char> vowelSet = { 'a', 'e', 'i', 'o', 'u' };
        unordered_set<string> wordSet(wordlist.begin(), wordlist.end());
        unordered_map<string, vector<int>> lowerWordsToIdx;
        for (int i = 0; i < wordlist.size(); i++) {
            lowerWordsToIdx[toLower(wordlist[i])].push_back(i);
        }
        unordered_map<string, vector<int>> devowelToIdx;
        for (int i = 0; i < wordlist.size(); i++) {
            auto devowelledWord = devowel(wordlist[i], vowelSet);
            devowelToIdx[devowelledWord].push_back(i);
        }
        vector<string> res;
        for (const auto& q : queries) {
            if (wordSet.count(q)) {
                res.push_back(q);
                continue;
            }
            auto lq = toLower(q);
            if (lowerWordsToIdx.count(lq)) {
                res.push_back(wordlist[lowerWordsToIdx[lq].front()]);
                continue;
            }
            auto devowelledWord = devowel(q, vowelSet);
            if (devowelToIdx.count(devowelledWord)) {
                res.push_back(wordlist[devowelToIdx[devowelledWord].front()]);
                continue;
            }
            res.push_back("");
        }
        return res;
    }
};
int main()
{
	return 0;
}